package com.example.kam.mymediapalyer.util;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

import jcifs.smb.SmbFile;

/**
 * Created by kam on 2017/2/12.
 */

public class Player {

    public static  void play(Context context ,SmbFile file) {
        String ipVal = FileUtil.ip;
        int portVal = FileUtil.port;
        String httpReq = "http://" + ipVal + ":" + portVal + "/smb=";
        try {
            String path = file.getPath().substring(6);
            path = URLEncoder.encode(path, "UTF-8");
            String url = httpReq + path;
            Intent it = new Intent(Intent.ACTION_VIEW);
            Uri uri = Uri.parse(url);
            it.setDataAndType(uri, "video/mp4");
            context.startActivity(it);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
    }
}
